package com.example.hengjun.operation_oracle.aboutfilter.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

// /不会拦截页面，只会拦截路径。
// /* 会路径和页面
// 例如/ 当请求为/user/login的时候可以被拦截，当为/page/login.html页面的时候不拦截
// /* 当请求为/user/login的时候可以被拦截，当为/page/login.html页面的时候也会被拦截
// /* ： 匹配一级，即 /add , /query 等

// /** ： 匹配多级，即 /add , /add/user, /add/user/user… 等

@WebFilter(urlPatterns = "/oracle/find/*",filterName = "demofilter")
public class DemoFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

        System.out.println("Remote Host: " + servletRequest.getRemoteHost());
        System.out.println("Remote Address: " + servletRequest.getLocalAddr());
        filterChain.doFilter(servletRequest,servletResponse);
    }

    @Override
    public void destroy() {

    }
}

